package exception;

/**
 * 异常的抛出
 */
public class ThrowDemo {
    public static void main(String[] args) {
        Student s = new Student();
        try {
            s.setAge(-1);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("年龄为:"+s.getAge()+"岁了");




        /*
        Student s = new Student();
        try{
            s.setAge(10);
            System.out.println("此人年龄为:"+s.getAge()+"岁了");
        }catch(Exception e){
            System.out.println("年龄不合法");
        }
         */

    }
}
